package com.zhigongtech.tender.sys.service;

import org.springframework.cache.annotation.Cacheable;

import com.baomidou.mybatisplus.extension.service.IService;
import com.zhigongtech.common.consts.CacheConst;
import com.zhigongtech.common.exception.NomalException;
import com.zhigongtech.extension.entry.vo.AccountVo;
import com.zhigongtech.tender.sys.entity.User;

/**
 * <p>
 * SYS_USER 系统用户 服务类
 * </p>
 *
 * @author Alan
 * @since 2019-05-28
 */
public interface IUserService extends IService<User> {

	/**
	 * 
	 * @Title: getOneByAccount   
	 * @Description: 根据登录账号，返回用户VO信息 
	 * by Alan 2019-05-28 14:13:10
	 * @param account user login account
	 * @return      
	 * @return  AccountVo
	 */
	@Cacheable(value=CacheConst.CACHE_ACCOUTVO, key="#account")
	public AccountVo getOneByAccount(String account) throws NomalException;
	
	/**
	 * 
	 * @Title: getUserByAccount   
	 * @Description: 内部程序使用，会将password查询出来
	 * by Alan 2019-06-03 15:20:05
	 * @param account
	 * @return
	 * @throws NomalException      
	 * @return  User
	 */
	@Cacheable(value=CacheConst.CACHE_USER, key="#account")
	public User getUserByAccount(String account) throws NomalException;
	
	/**
	 * 
	 * @Title: getEncryptedPassword   
	 * @Description: 反馈出加密密码
	 * by Alan 2019-06-03 16:36:44
	 * @param password 明文密码
	 * @param salt 密码盐，可以采用默认的BCrypt.gensalt()方法获取盐值
	 * @return
	 * @throws NomalException      
	 * @return  String
	 */
	public String getEncryptedPassword(String password, String salt) throws NomalException;
	
	/**
	 * 
	 * @Title: checkPasswd    
	 * @Description: 检查密码是否正确
	 * by Alan 2019-06-03 17:00:23
	 * @param newPwd 明文密码
	 * @param secretPwd 数据库的密文
	 * @return      
	 * @return  boolean
	 */
	public boolean checkPasswd(String newPwd, String secretPwd);
	
	/**
	 * 
	 * @Title: getNewSalt   
	 * @Description: 获取盐 
	 * by Alan 2019-06-03 17:01:29
	 * @return      
	 * @return  String
	 */
	public String getNewSalt();
}
